import 'package:enterprise_v8/app/components/custom_app_bar.dart';
import 'package:enterprise_v8/app/core/core.dart';
import 'package:enterprise_v8/app/core/utils/file_util.dart';

/// 图片展示
class PhotoShowPage extends StatefulWidget {
  const PhotoShowPage({required this.url, super.key, this.title});

  /// 图片链接
  final String url;

  /// 标题
  final String? title;

  @override
  State<PhotoShowPage> createState() => _PhotoShowPageState();
}

class _PhotoShowPageState extends State<PhotoShowPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar(
        title: Text(
          widget.title ?? '',
          style: TextStyle(fontSize: 17.w),
        ),
        actions: [
          IconButton(
            onPressed: () {
              FileUtils.downloadFile(widget.url, type: 'image/jpeg');
            },
            icon: const Icon(Icons.share),
          ),
        ],
      ),
      body: InteractiveViewer(
        child: Image.network(
          widget.url,
          height: double.infinity,
        ),
      ),
    );
  }
}
